package com.flute.framework.index;

import java.io.File;
import java.io.IOException;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;

public class RawSearchTest {

	public static void main(String[] args) throws IOException {
		IndexSearcher searcher = new IndexSearcher(FSDirectory
				.open(new File("search/song/A")));

		TopDocs tds = searcher.search(new PrefixQuery(new Term("songname_jq", "张学")), 10);

		ScoreDoc[] sds = tds.scoreDocs;
System.out.println(tds.totalHits);
		for (int i = 0; i < sds.length; i++) {
			System.out.println(searcher.doc(sds[i].doc).getField("song_name")
					.stringValue());
		}
	}

}
